package net.feixiang.creational.prototype;

/**
 * 简历类
 * <p>
 * 包含姓名、性别、年龄和工作经历。实现了 Cloneable 接口以支持深拷贝。
 * </p>
 *
 * @author 飞翔
 * @see <a href="https://www.feixiang.net/Java%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/%E7%AC%AC%E4%B8%80%E7%AB%A0%E3%80%81%E5%88%9B%E5%BB%BA%E5%9E%8B%E6%A8%A1%E5%BC%8F/15.html">原型模式</a>
 */
public class Resume implements Cloneable {
    private String name; // 姓名
    private String gender; // 性别
    private int age; // 年龄
    private WorkExperience workExperience; // 工作经历

    // 构造方法
    public Resume(String name, String gender, int age,
                     WorkExperience workExperience) {
        this.name = name;
        this.gender = gender;
        this.age = age;
        this.workExperience = workExperience;
    }

    // 实现 clone 方法，深拷贝
    @Override
    protected Resume clone() {
        // 深拷贝：复制工作经历对象
        WorkExperience clonedWorkExperience = new WorkExperience(
                        this.workExperience.getCompany(),
                        this.workExperience.getWorkYears());
        return new Resume(this.name, this.gender, this.age, clonedWorkExperience);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public WorkExperience getWorkExperience() {
        return workExperience;
    }

    public void setWorkExperience(WorkExperience workExperience) {
        this.workExperience = workExperience;
    }

    @Override
    public String toString() {
        return "Resume{" +
                "name='" + name + '\'' +
                ", gender='" + gender + '\'' +
                ", age=" + age +
                ", \nworkExperience=" + workExperience +
                '}';
    }
}